﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace Travel.Web.banner_image
{
    public partial class Add : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
                       
        }

        		protected void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(!PageValidate.IsNumber(txtid.Text))
			{
				strErr+="id格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtbanner_id.Text))
			{
				strErr+="banner的主键格式错误！\\n";	
			}
			if(this.txttitle.Text.Trim().Length==0)
			{
				strErr+="标题可显示在页面上不能为空！\\n";	
			}
			if(this.txtsrc.Text.Trim().Length==0)
			{
				strErr+="超链接不能为空！\\n";	
			}
			if(!PageValidate.IsNumber(txtserial_no.Text))
			{
				strErr+="排序指定为第几个显示格式错误！\\n";	
			}
			if(!PageValidate.IsDateTime(txtcreated_on.Text))
			{
				strErr+="created_on格式错误！\\n";	
			}
			if(this.txtcreated_by.Text.Trim().Length==0)
			{
				strErr+="created_by不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtchanged_on.Text))
			{
				strErr+="changed_on格式错误！\\n";	
			}
			if(this.txtchanged_by.Text.Trim().Length==0)
			{
				strErr+="changed_by不能为空！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int id=int.Parse(this.txtid.Text);
			int banner_id=int.Parse(this.txtbanner_id.Text);
			string title=this.txttitle.Text;
			string src=this.txtsrc.Text;
			int serial_no=int.Parse(this.txtserial_no.Text);
			DateTime created_on=DateTime.Parse(this.txtcreated_on.Text);
			string created_by=this.txtcreated_by.Text;
			DateTime changed_on=DateTime.Parse(this.txtchanged_on.Text);
			string changed_by=this.txtchanged_by.Text;

			Travel.Model.banner_image model=new Travel.Model.banner_image();
			model.id=id;
			model.banner_id=banner_id;
			model.title=title;
			model.src=src;
			model.serial_no=serial_no;
			model.created_on=created_on;
			model.created_by=created_by;
			model.changed_on=changed_on;
			model.changed_by=changed_by;

			Travel.BLL.banner_image bll=new Travel.BLL.banner_image();
			bll.Add(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","add.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
